package com.piano.web.controller.manage;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.piano.common.annotation.Log;
import com.piano.common.enums.BusinessType;
import com.piano.manage.domain.TAudition;
import com.piano.manage.service.ITAuditionService;
import com.piano.framework.web.base.BaseController;
import com.piano.common.page.TableDataInfo;
import com.piano.common.base.AjaxResult;
import com.piano.common.utils.poi.ExcelUtil;

/**
 * 试听管理 信息操作处理
 * 
 * @author pinao
 * @date 2019-02-26
 */
@Controller
@RequestMapping("/manage/tAudition")
public class TAuditionController extends BaseController
{
    private String prefix = "manage/tAudition";
	
	@Autowired
	private ITAuditionService tAuditionService;
	
	@RequiresPermissions("manage:tAudition:view")
	@GetMapping()
	public String tAudition()
	{
	    return prefix + "/tAudition";
	}
	
	/**
	 * 查询试听管理列表
	 */
	@RequiresPermissions("manage:tAudition:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(TAudition tAudition)
	{
		startPage();
        List<TAudition> list = tAuditionService.selectTAuditionList(tAudition);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出试听管理列表
	 */
	@RequiresPermissions("manage:tAudition:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TAudition tAudition)
    {
    	List<TAudition> list = tAuditionService.selectTAuditionList(tAudition);
        ExcelUtil<TAudition> util = new ExcelUtil<TAudition>(TAudition.class);
        return util.exportExcel(list, "tAudition");
    }
	
	/**
	 * 新增试听管理
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存试听管理
	 */
	@RequiresPermissions("manage:tAudition:add")
	@Log(title = "试听管理", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(TAudition tAudition)
	{		
		return toAjax(tAuditionService.insertTAudition(tAudition));
	}

	/**
	 * 修改试听管理
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Integer id, ModelMap mmap)
	{
		TAudition tAudition = tAuditionService.selectTAuditionById(id);
		mmap.put("tAudition", tAudition);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存试听管理
	 */
	@RequiresPermissions("manage:tAudition:edit")
	@Log(title = "试听管理", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(TAudition tAudition)
	{		
		return toAjax(tAuditionService.updateTAudition(tAudition));
	}
	
	/**
	 * 删除试听管理
	 */
	@RequiresPermissions("manage:tAudition:remove")
	@Log(title = "试听管理", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(tAuditionService.deleteTAuditionByIds(ids));
	}
	
}
